package com.javatest.springbootcache01.config;

import java.lang.reflect.Method;
import java.util.Arrays;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2019/3/22 13:58
 */
@Configuration
public class MyCacheConfig {
    @Bean("myKeyGernerator")
    public KeyGenerator keyGenerator() {
        System.out.println("user myKeyGernerator");
        return new KeyGenerator() {
            @Override
            public Object generate(Object o, Method method, Object... objects) {
                return method.getName() + "[" + Arrays.asList(objects) + "]";
            }
        };
    }


}
